package cn.edu.hit.calculation;

import java.util.Arrays;
import java.util.List;

/**
 * Created by zchai on 2018/4/7.
 */

public class ClassificationUtil {

    private static final String[] numbersWithout0 = {"1","2","3","4","5","6","7","8","9"};
    private static final String[] numbers = {"0","1","2","3","4","5","6","7","8","9"};
    private static final String[] operations = {"+","*","%"};
    private static final String subtraction = "-";
    private static final String equal = "=";
    private static final String zero = "0";
    private static final String point = ".";

    private static List<String> numbersWithout0List;
    private static List<String> numbersList;
    private static List<String> operationsList;

    public static int getClassification(String input) {
        int classification = -1;

        //初始化三种输入
        numbersWithout0List = Arrays.asList(numbersWithout0);
        numbersList = Arrays.asList(numbers);
        operationsList = Arrays.asList(operations);

        if (numbersWithout0List.contains(input)) {
            //1-9
            classification = 0;
        }
        if (input.equals(zero)) {
            //0
            classification = 1;
        }
        if (operationsList.contains(input)) {
            //+ * %
            classification = 2;
        }
        if (input.equals(subtraction)) {
            //-
            classification = 3;
        }
        if (input.equals(point)) {
            //.
            classification = 4;
        }
        if (input.equals(equal)) {
            //=
            classification = 5;
        }

        return classification;
    }

}
